﻿@model OrderSystem.Models.Users
@{
    ViewBag.Title = "Create New User";
    ViewBag.Message = "This page is appointed for creating new user for particular role"; 
    Layout = "~/Views/Shared/_Layout.cshtml";
    List<SelectListItem> regions = new List<SelectListItem>();
    SelectListItem northRegion = new SelectListItem();
    northRegion.Text = "North";
    northRegion.Value = "North";
    regions.Add(northRegion);
    SelectListItem southRegion = new SelectListItem();
    southRegion.Text = "South";
    southRegion.Value = "South";
    regions.Add(southRegion);
    SelectListItem westRegion = new SelectListItem();
    westRegion.Text = "West";
    westRegion.Value = "West";
    regions.Add(westRegion);
    SelectListItem eastRegion = new SelectListItem();
    eastRegion.Text = "East";
    eastRegion.Value = "East";
    regions.Add(eastRegion);
}

<h2>@ViewBag.Title</h2>
<p>@ViewBag.Message</p>

<script src="../../Scripts/jquery-1.5.1.min.js"></script>
<script src="../../Scripts/jquery-ui-1.8.11.min.js"></script>

<script language="javascript" type="text/javascript">
    $(document).ready(function () {
        $("button.cancel").click(function () {
            $("#dialog").dialog({
                buttons: {
                    "Yes": function () {
                        document.location.href='@Url.Action("Index", "OrderSystemUser")';
                    },
                    "No": function () {
                        $(this).dialog("close");
                    }
                }
            });

        });

    });
</script>
@using (Html.BeginForm())
{
    <fieldset>
        <div class="editor-label">
            @Html.LabelFor(model => model.Login)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Login)
            @Html.ValidationMessageFor(model => model.Login)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.UserFName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.UserFName)
            @Html.ValidationMessageFor(model => model.UserFName)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.UserLName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.UserLName)
            @Html.ValidationMessageFor(model => model.UserLName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Password)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Password)
            @Html.ValidationMessageFor(model => model.Password)
            
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.ConfirmPassword)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.ConfirmPassword)
            @Html.ValidationMessageFor(model => model.ConfirmPassword)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Mail)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Mail)
            @Html.ValidationMessageFor(model => model.Mail)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Region)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.Region, regions)
        </div>
        
        <div class="radio-button-list-label">
            @Html.LabelFor(model => model.Role)
        </div>
        <div class="radio-button-list">                     
            @Html.RadioButtonFor(model => model.Role, "Administrator") Administrator <br />
            @Html.RadioButtonFor(model => model.Role, "Merchandiser") Merchandiser <br />
            @Html.RadioButtonFor(model => model.Role, "Supervisor") Supervisor <br />
            @Html.RadioButtonFor(model => model.Role, "Customer", new { Checked = "checked" }) Customer
        </div>

        <p>
            <input type="submit" value="Create" />
            <button type="button" value="Cancel" class="cancel">Cancel</button>
            <button type="reset" value="Refresh">Refresh</button>
        </p>
        <div style="visibility:hidden">
            <div id="dialog" title="Warning" >
                Are you sure you want to cancel operation?<br />All data will be lost.
            </div>
        </div>
    </fieldset>
}